<template>
  <div>
    <div class="index">
      <div @click="CheckMap('pie')">
        <span>饼图</span>
      </div>
      
      <div @click="CheckMap('histogram')">
        <span>直方图</span>
      </div>
      <div @click="CheckMap('forceDirected')">
        <span>力导向图</span>
      </div>
      <div @click="CheckMap('three')">
        <span>树状图</span>
      </div>
      <div @click="CheckMap('org')">
        <span>组织架构图</span>
      </div>
      <div @click="CheckMap">
        <span></span>
      </div>
    </div>
    <div v-if="map" @click="CloseMap" class="map">
      <div @click.stop class="mapbox" ref='map'>
        <Maps class="Maps" :width='mapWidth' :height='mapHeight' :mapName='mapName'/>
      </div>
    </div>
  </div>
</template>

<script>
const Maps = () => import('@/components/maps/map.js');
export default {
  name: "index",
  components: {
    Maps
  },
  data() {
    return {
      map: false,
      mapName: '',
      mapHeight: 0,
      mapWidth: 0,
    };
  },
  methods: {
    CheckMap: function(mapName) {
      // let mapHeightPercentage = window.getComputedStyle(this.$refs.map).height.split('%')[0];
      // let windowHeight = document.body.clientHeight;
      // this.mapHeight = parseInt(mapHeightPercentage) / 100 * windowHeight;    
      // let mapWidthPercentage = window.getComputedStyle(this.$refs.map).width.split('%')[0];
      let windowWidth = document.body.clientWidth;
      this.mapWidth = 0.8 * windowWidth;

      let windowHeight = document.body.clientHeight;
      this.mapHeight = 0.8 * windowHeight;    
      this.mapName = mapName;
      this.map = true;
    },
    CloseMap: function() {
      this.map = false;
    }
  }
};
</script>

<style scoped>
.index {
  display: grid;
  width: 100%;
  height: 100%;
  grid-column-gap: 10px;
  grid-row-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.index div {
  background: pink;
  cursor: pointer;
  display: flex;
  color: #ffffff;
  font-size: 3vw;
}
.index div span {
  margin: auto;
}
.map {
  display: flex;
  position: fixed;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}
.mapbox {
  width: 80%;
  height: 80%;
  background: #ffffff;
  margin: auto;
}
</style>